/*******************************************************************************
 * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
 * This program and the accompanying materials are made available under
 * the terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Marc R. Hoffmann - initial API and implementation
 *
 *******************************************************************************/
package org.jacoco.core.data;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 调试生成二进制文件
 *
 * @author liaozhiyong
 *
 */
public class DataInputstreamTest {

	public static void main(String[] args) {
		try {
			write();
			read();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static void read() throws IOException {
		DataInputStream dis = new DataInputStream(
				new FileInputStream("Dos" + ".txt"));
		{
			byte a = dis.readByte();
			int b = dis.readInt();
			char c = dis.readChar();
			float d = dis.readFloat();
			System.out.println(a);
			System.out.println(b);
			System.out.println(c);
			System.out.println(d);
		}

		System.out.println("--------------------");
		byte a = dis.readByte();
		long b = dis.readLong();
		String s = dis.readUTF();
		int i = dis.read();
		dis.close();

		System.out.println(a);
		System.out.println(b);
		System.out.println(s);
		System.out.println(i);
	}

	public static void write() throws IOException {
		DataOutputStream out = new DataOutputStream(
				new FileOutputStream("DOS.txt"));
		out.writeByte(123);
		out.writeInt(123);
		out.writeChar('a');
		out.writeFloat(123.123f);

		out.writeByte(12);
		out.writeLong(1000);
		out.writeUTF("com.cn");
		out.write(1);
		out.close();
	}

}
